//
//  NumericalTransformationTools.swift
//  APP
//
//  Created by Rdxer on 2017/12/7.
//  Copyright © 2017年 Rdxer. All rights reserved.
//

import Foundation
import UIKit


fileprivate let _3_5_320:CGFloat = 320
fileprivate let _4_0_320:CGFloat = 320
     public let _4_7_375:CGFloat = 375
fileprivate let _5_5_414:CGFloat = 414
fileprivate let _5_8_375:CGFloat = 375  // 375 x 812。
fileprivate let _1080:CGFloat = 1080


extension CGFloat{
    
    public var from_5_5_414: CGFloat {
        return from(sourceWidth: _5_5_414)
    }

    public var from_4_7_375: CGFloat {
        return from()
    }
    
    /// 来源 1080 * 1920
    public var from1080: CGFloat {
        return from(sourceWidth: _1080)
    }
    
    /// 转化 到 竖的方向 非 16/9 会有缩放比
    /// Vertical
    public var toV: CGFloat {
        
        let scale = (self / UIScreen.main.bounds.width)
        
        let scaleV = scale / 9.0 * 16.0
        
        return UIScreen.main.bounds.height * scaleV
    }
    
    
    
    /// -----------------
    
    /// 标示来源 转成当前屏幕的 大小, 仅按照 宽度的比例
    public func from(sourceWidth:CGFloat = _4_7_375) -> CGFloat {
        
        let scale = self / sourceWidth
        let difference = UIScreen.main.bounds.width * scale
        
        return difference
    }
    
//    public func from(sourceWidth:CGFloat = _4_7_375) -> CGFloat {
//        return toCurrentScreen(fromScale: transformScale(fromWidth: sourceWidth))
//    }
    
//    fileprivate func transformScale(fromWidth:CGFloat)->CGFloat{
//        let scale = self / fromWidth
//        return scale
//    }
//
//    fileprivate func toCurrentScreen(fromScale:CGFloat)->CGFloat{
//        let difference = UIScreen.main.bounds.width * fromScale
//        return difference
//    }
    
}


extension Int{
    public var from_5_5_414: CGFloat {
        return CGFloat.init(self).from_5_5_414
    }
    
    public var from_4_7_375: CGFloat {
        return CGFloat.init(self).from_4_7_375
    }
    
    /// 来源 1080 * 1920
    public var from1080: CGFloat {
        return CGFloat.init(self).from1080
    }
}
